import request from '@/utils/request'
import store from '@/store'
//const ascriptionId = store.state.userInfo.ascriptionId;

// 页面内容 左侧树
export function getPage(queryParams) {
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize
  }
  return request({
    url: '/getDictionaryPage',
    method: 'post',
    data: data
  })
}

// 数据列表
export function listData(queryParams) {
  console.log('ascriptionId---', store.state.userInfo.ascriptionId)
  const data = {
    ascriptionId: store.state.userInfo.ascriptionId,
    currentPage: queryParams.currentPage,
    pagesize: queryParams.pagesize,
    dictId: queryParams.dictId,
    keywords: queryParams.keywords
  }
  return request({
    url: '/getDictionaryList',
    method: 'post',
    data: data
  })
}

// 新增
export function addData(val) {
  const data = {
    projectContent: {
      ascriptionId: store.state.userInfo.ascriptionId,
      tid: val.tid, //顶级id
      dictId: val.dictId, //上级id
      titleName: val.titleName, //标题名称
      pathIds: val.pathIds,
      sort: val.sort //位置排序
    }
  }
  return request({
    url: '/addDictionary',
    method: 'post',
    data: data
  })
}

// 获取单条数据
export function getData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/getDictionaryData',
    method: 'post',
    data: data
  })
}

// 修改
export function updateData(val) {
  const data = {
    projectContent: {
      theid: val.id,
      titleName: val.titleName,
      sort: val.sort
    }
  }
  // theid
  return request({
    url: '/updateDictionary',
    method: 'post',
    data: data
  })
}

// 删除
export function delData(theid) {
  const data = {
    theid
  }
  return request({
    url: '/delDictionary',
    method: 'post',
    data: data
  })
}

// 批量删除   idListStr id列表  逗号隔开
export function delMultiData(idListStr) {
  const data = {
    idListStr
  }
  return request({
    url: '/delDictionary',
    method: 'post',
    data: data
  })
}

// exportData